package com.asj.house.controller;


import com.asj.house.entity.HouseUser;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import com.asj.house.service.HouseUserService;
import com.asj.house.vo.param.LoginParam;
import com.asj.house.vo.param.UserParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-03-16
 */
@RestController
@RequestMapping("/house-user")
@Slf4j
@Api(value = "用户管理", tags = "用户管理")
public class HouseUserController {

    @Resource
    private HouseUserService houseUserService;

    @PostMapping("/login")
    @ApiOperation(value = "管理后台登陆功能")
    public RespEntity<HouseUser> login(@RequestBody LoginParam loginParam) {
        RespEntity<HouseUser> respEntity = houseUserService.login(loginParam);
        return respEntity;
    }

    @GetMapping("/list")
    @ApiOperation(value = "用户列表")
    public RespTable<List<HouseUser>> queryAllUser(UserParam userParam) {
        RespTable<List<HouseUser>> respTable = houseUserService.queryAllUser(userParam);
        return respTable;
    }

    @GetMapping("/send")
    @ApiOperation(value = "发送短信验证码")
    @ApiImplicitParam(paramType = "query", dataType = "String", name = "mobile", value = "手机号", required = true)
    public RespEntity<Integer> sendMsg(@RequestParam(value = "mobile", required = true) String mobile) {
        RespEntity<Integer> respEntity = houseUserService.sendMsg(mobile);
        return respEntity;
    }

}
